package com.wfw.dto;

import com.wfw.model.OrderDetail;
import com.wfw.model.OrderMaster;
import com.wfw.utils.BeanConvertUtil;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class OrderMasterDto {

    private String orderId;

    private String buyerName;

    private String buyerPhone;

    private String buyerAddress;

    private String buyerOpenid;

    private BigDecimal orderAmount;

    private Byte orderStatus;

    private Byte payStatus;

    private Date createTime;

    private Date updateTime;

    List<OrderDetail> orderDetailList;

    public OrderMaster convertFor(){
        ConvertToOrderMaster convert=new ConvertToOrderMaster();
        return convert.convert(this);
    }

    private class ConvertToOrderMaster implements BeanConvertUtil<OrderMaster,OrderMasterDto>{

        @Override
        public OrderMaster convert(OrderMasterDto orderMasterDto) {
            OrderMaster orderMaster=new OrderMaster();
            BeanUtils.copyProperties(orderMasterDto,orderMaster);
            return orderMaster;
        }
    }
}
